package com.zhenhunfan.learnliquibase.config;

import liquibase.database.DatabaseFactory;
import liquibase.integration.spring.SpringLiquibase;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * <p>Title:</p>
 * <p>Description:</p>
 *
 * @author zhanghong
 * @date 2023/9/8
 */
@Configuration
public class LiquibaseConfig {
    @Bean
    public SpringLiquibase liquibase(DataSource dataSource){
        SpringLiquibase liquibase = new SpringLiquibase();

        // 支持达梦数据库
//        DatabaseFactory.getInstance().register(new DMDatabase());

        liquibase.setDataSource(dataSource);
        liquibase.setChangeLog("classpath:db/changelog/init/db.changelog-init.xml");
        liquibase.setShouldRun(true);
        return liquibase;
    }
}
